home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1997 August / Walnut Creek CDROM.7z / LISTINGS / V_13_04 / CHAPMAN2 / CHAPMAN2.ZIP / COMPLAIN.HPP < prev    next >
Encoding:
C/C++ Source or Header  |  1994-02-22  |  2.0 KB  |  46 lines

  1. /* complain.hpp / declaration for complaint printer */
  2.  
  3. #ifndef COMPLAIN_HPP                    /* in case of double inclusion */
  4. #define COMPLAIN_HPP
  5.  
  6. /* this utility allows error messages to be stored in a file. when a keyed */
  7. /* error message is to be printed, the file is re-opened and the text read. */
  8. /* this then becomes the format string for a printf()-type call. note that */
  9. /* the order of the format specifiers (%s, %d, etc.) inside cannot change! */
  10. /* this does restrict rewording or translation into other languages... */
  11.  
  12. /* blank lines are ignored; lines beginning with '#' are comments. */
  13. /* otherwise the line must be of the form <identifier> ':' <text>. */
  14. /* the newline at the end of the line is included in the message; if */
  15. /* there is a '\\' immediately in front of the newline, the newline */
  16. /* is quoted and the next line is added to the message. in this way */
  17. /* messages can have embedded newlines. */
  18.  
  19. /* there can be more than one error dictionary - each application can have */
  20. /* its own. complaint_text() returns non-zero on error, should the file */
  21. /* disappear during program execution or if the keyed message isn't found. */
  22.  
  23. /* key_defined() and complaint_text() return 1 on success and 0 otherwise. */
  24.  
  25. /* complaint dictionaries can't be copied (there's no reason to). */
  26.  
  27. class complain_ptr;                     /* internal key definition */
  28.  
  29. class complaint_dict {
  30.     public:
  31.         complaint_dict(const char *filename);  /* setup */
  32.         ~complaint_dict(void);
  33.         int key_defined(const char *name) const;
  34.         int complaint_text(const char *name,
  35.                            char *line,int linelen) const;
  36.         const char *filename(void) const { return _filename; }
  37.     private:
  38.         char *_filename;
  39.         complain_ptr *complain_table;
  40.         complaint_dict(const complaint_dict &other);  /* unimplemented */
  41.         complaint_dict &operator =(const complaint_dict &other);
  42. };  /* end of class complaint_dict */
  43.  
  44. #endif  /* COMPLAIN_HPP */
  45.  
  46.